<template>
    <IContent v-model="componentProps">
        <ISearch v-model="search">
            <FormItem label="产品料号">
                <Input v-model="search.unique" size="small"></Input>
            </FormItem>
            <FormItem :label-width="1">
                <ButtonGroup>
                    <Button type="primary" icon="ios-search" size="small" @click="getLists(1)">搜索</Button>
                </ButtonGroup>
            </FormItem>
        </ISearch>
        <ITable :current="page.current" :table="table" :total="page.total" @on-page-change="pageChange"
                :loading="loading">
            <template slot-scope="{row, index}" slot="unit">
                <RemoteSpan :value="row.unit" url="common/select/unit"></RemoteSpan>
            </template>
            <template slot-scope="{row, index}" slot="country">
                <RemoteSpan :value="row.country" url="common/select/country"></RemoteSpan>
            </template>
            <template slot-scope="{row, index}" slot="currency">
                <RemoteSpan :value="row.currency" url="common/select/currency"></RemoteSpan>
            </template>
            <template slot-scope="{row, index}" slot="action">
                <ButtonGroup>
                    <Button size="small" @click="openComponent(`IUpdate`, row)">修改</Button>
                </ButtonGroup>
            </template>
        </ITable>
        <component slot="component" v-if="componentProps.value" :is="componentProps.view" v-model="componentProps.value"
                   :props="componentProps.props"
                   @input="getLists(page.current)"></component>
    </IContent>
</template>

<script>
    import IContent from "../../../../components/layout/IContent";
    import IContentMixins from "../../../../mixins/iContentMixins";
    import ISearch from "../../../../components/layout/ISearch";
    import ITable from "../../../../components/layout/ITable";
    import RemoteSpan from "../../../../components/layout/RemoteSpan";
    import RemoteSelect from "../../../../components/form/remoteSelect";

    export default {
        name: "index",
        components: {
            IUpdate: () => import("./update"),
            RemoteSelect, RemoteSpan, ITable, ISearch, IContent
        },
        mixins: [IContentMixins],
        data() {
            return {
                search: {status: 4},
                table: {
                    columns: [{
                        title: '料号',
                        key: 'unique',
                        width: 150
                    }, {
                        title: '产品名称',
                        key: 'name',
                        width: 150
                    }, {
                        title: '商品编码',
                        key: 'hs_code',
                        width: 150
                    }, {
                        title: '产品毛重',
                        key: 'weight',
                        width: 100
                    }, {
                        title: '原产国',
                        slot: 'country',
                        width: 100
                    }, {
                        title: '单位',
                        slot: 'unit',
                        width: 100
                    }, {
                        title: '币种',
                        slot: 'currency',
                        width: 100
                    }, {
                        title: '法一数量',
                        key: 'qy1',
                        width: 100
                    }, {
                        title: '法二数量',
                        key: 'qy2',
                        width: 100
                    }, {
                        title: '申报要素',
                        key: 'element',
                        minWidth: 400
                    }, {
                        title: '操作',
                        slot: 'action',
                        width: 100
                    }]
                },
            }
        },
        methods: {
            getLists(page) {
                this._lists(`product/index`, page);
            }
        }
    }
</script>

<style scoped>

</style>
